<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="content">
        <div class="panel panel-default panel-intro">

            <div class="panel-body">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane fade active in" id="one">
                        <div class="widget-body no-padding">

                            <div class="bootstrap-table">
                                <div class="commonsearch-table ">
                                    <fieldset>
                                        <div class="row">
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="c-storehouse_id" class="control-label col-xs-4">入库仓库</label>
                                                <div class="col-xs-8">
                                                    <input id="c-storehouse_id" data-rule="required" data-source="data/storehouse/index" data-field="name" class="form-control selectpage"  type="text" value="{$row['storehouse_id']}" disabled>
                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="c-source_storehouse_id" class="control-label col-xs-4">出库仓库</label>
                                                <div class="col-xs-8">
                                                    <input id="c-source_storehouse_id" data-rule="required" data-source="data/storehouse/index" data-field="name" class="form-control selectpage" name="source_storehouse_id" type="text" value="{$row['source_storehouse_id']}" disabled>
                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="explain" class="control-label col-xs-4">说明</label><div class="col-xs-8">
                                                <input type="text" class="form-control" name="explain" value="{$row['explain']}" placeholder="说明" id="explain" data-index="13">
                                            </div>

                                            </div>
<!--                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">-->
<!--                                                <label for="allfare" class="control-label col-xs-4">运费</label><div class="col-xs-8">-->
<!--                                                <input type="number" class="form-control" name="allfare" value="" placeholder="运费" id="allfare" data-index="14">-->
<!--                                            </div>-->
                                                <!--                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3"><label for="abstract" class="control-label col-xs-4">摘要</label><div class="col-xs-8">-->
                                                <!--                                                <input type="text" class="form-control" name="abstract" value="" placeholder="摘要" id="abstract" data-index="14">-->
                                                <!--                                            </div>-->
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                            </div>


                            </div>
                            </div><div class="columns-right pull-right" style="margin-top:10px;margin-bottom:10px;">
                            </div>
                                <table id="table" class="table table-striped table-bordered table-hover table-nowrap"  data-operate-edit="1" data-operate-del="1" width="100%">
                                    <thead>
                                    <tr>
                                        <th style="text-align: center; vertical-align: middle; " data-field="id"><div class="th-inner ">Id</div></th>
                                        <!--                                <th style="text-align: center; vertical-align: middle; " data-field="createtime"><div class="th-inner ">出库仓库</div></th>-->
                                        <th style="text-align: center; vertical-align: middle; " ><div class="th-inner ">商品编号</div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="number"><div class="th-inner ">商品名称</div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="status"><div class="th-inner ">产地</div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="supplier_id"><div class="th-inner ">规格</div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="operator"><div class="th-inner ">账面库存</div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="company"><div class="th-inner ">虚拟库存</div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="order_goods_total"><div class="th-inner ">申请数量</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="arrival_total"><div class="th-inner ">单位</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="operate"><div class="th-inner ">备注</div><div class="fht-cell"></div></th>
<!--                                        <th style="text-align: center; vertical-align: middle; " data-field="operate"><div class="th-inner ">操作</div><div class="fht-cell"></div></th>-->
                                    </tr>
                                    </thead>
                                    <tbody data-listidx="0" class="connnn">
                                        {volist name="plist" id="vo"}
                                            <tr data-index="0">
                                                <td style="text-align: center; vertical-align: middle; ">
                                                    <input name="row[{$vo.id}][goods_id]" value="{$vo.id}" style="display: none" class="gid gids{$vo.id}">{$vo.id}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.number}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="title">{$vo.title}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.place_origin}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.specs}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="stock">{$vo.stock}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="xstock">{$vo.xstock}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="">
                                                    <input type="text" onkeyup="onlynumber(this);" style="display: none" class="requisition_num" name="row[{$vo.id}][goods_num]" value="{$vo.goods_num}">
                                                    <span class=" ">{$vo.goods_num}</span>
                                                </td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.unit}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="">
                                                    <input type="text" class="form-control" style="display: none" value="{$vo.remark}" name="row[{$vo.id}][remark]">
                                                    <span class="tremark ">{$vo.remark}</span>
                                                </td>
<!--                                                <td style="text-align: center; vertical-align: middle; ">-->
<!--                                                    <a href="javascript:;" class="btn btn-xs btn-danger btn-delone" data-toggle="tooltip" title="" data-table-id="table" data-field-index="15" data-row-index="0" data-button-index="2" data-original-title="删除"><i class="fa fa-trash"></i></a>&nbsp;&nbsp;<a href="javascript:;" class="btn btn-xs btn-success btn-caigou" title="采购" data-table-id="table" data-field-index="13" data-row-index="0" data-button-index="0"><i class="fa fa-shopping-basket"></i></a></td>-->
                                            </tr>
                                        {/volist}
                                    </tbody>
                                    <tbody class="tbfoot" data-listidx="0" style="display: ">
                                        <td style="text-align: center; vertical-align: middle; ">合计</td>
                                        <!--                                        <td style="text-align: center; vertical-align: middle; "></td>-->
                                        <!--                            <td style="text-align: center; vertical-align: middle; "></td>-->
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; " class="zstock"></td>
                                        <td style="text-align: center; vertical-align: middle; " class="xstock"></td>
                                        <td style="text-align: center; vertical-align: middle; " class="allnum">0</td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; " ></td>
<!--                                        <td style="text-align: center; vertical-align: middle; "></td>-->
                                    </tbody>
                                </table>
                            </div>


                        </div>
                    </div>

                </div>
            </div>
        </div>

    </div>
    {if condition="$auth->check('purchase/allot/examine1') && $row.status == 1 "}
    <input type="hidden" name="status" value="1">
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed subpurchase">{:__('OK')}</button>
            <button type="submit" class="btn btn-default btn-embossed reset">驳回</button>
        </div>
    </div>
    {else /}

    {/if}
</form>

<div class="form-group layer-footer">
    {if condition="$row['status']>1 && $row['status']  < 6 "}
    <div class="col-xs-12 col-sm-3">
        <button type="submit" class="btn btn-danger btn-embossed cancelbill {:$auth->check('purchase/allot/cancelbill')?'':'hide'}">{:__('单据红冲')}</button>
    </div>
    {else /}
    {/if}
</div>


<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>
    $('.subpurchase').click(function () {
        $("input[name='status']").val(1)
    })
    $('.reset').click(function () {
        $("input[name='status']").val(2)
    })

    $('tbody').on('click','.xxgg',function () {
        input_index = $('.xxgg').index(this)
        $(this).find('span').attr('style','display:none')
        width = $(this).width()*0.73
        if(width <50){
            width =50;
        }
        // console.log(width)
        $(this).find('input').show()
        $(this).find('input').focus();
        $(this).find('input').select();
        $(this).find('input').attr('style','width:'+width+'px')
    })
    $('.connnn').on('blur','input',function () {
        $(this).hide();
        $(this).next().attr('style','display:')
        $(this).next().html($(this).val())
        count()
    })
    function count() {
        var anum = 0;//采购数量
        $('.connnn').find("tr").each(function(){
            tnum = $(this).find('.requisition_num').val()*1 //采购数量
            anum = anum*1 +tnum*1
        });
        $('.allnum').html(anum)
    }
    count()
</script>
